<?php
require_once 'mp3\Smarty.php';

$smarty = new mp3_Smarty();

require_once 'mp3\GestionarUsuari.php';
require 'mp3/ComprovarSessio.php';

echo $smarty->fetch('mp3\header.tpl');

if (array_key_exists('password', $_POST)){
	if ($_POST['pdp'] == $_POST['pdp_rep']) {
		mp3_GestionarUsuari::canviPass($_SESSION['username'], $_POST['pdp']);
		$smarty->assign('pass', 'ok');
		echo $smarty->fetch('mp3\index.tpl');
		echo $smarty->fetch('mp3\footer.tpl');
	}else {
		$smarty->assign('missatge', 'Les paraules de pas són diferents');
		echo $smarty->fetch('mp3\canviPass.tpl');
		echo $smarty->fetch('mp3\footer.tpl');
	}
}else{
	$smarty->assign('missatge', '');
	echo $smarty->fetch('mp3\canviPass.tpl');
	echo $smarty->fetch('mp3\footer.tpl');
}
?>
